<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>后台管理中心</title>
    
    <link rel="stylesheet" href="../css/layout.css" type="text/css" media="screen" />
    <!--[if lt IE 9]>
    <link rel="stylesheet" href="../css/ie.css" type="text/css" media="screen" />
    <script src="../js/html5.js"></script>
    <![endif]-->
    <script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../js/hideshow.js" type="text/javascript"></script>
    <script src="../js/jquery.tablesorter.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/jquery.equalHeight.js"></script>
    <script src="../api/billboard_api.js"></script>
<script type="text/javascript">
    setInterval(function() {
        var now = (new Date()).toLocaleString();
        $('.current-time').text(now);
    }, 1000);
</script>
<script type="text/javascript">
    $(document).ready(function() 
        { 
          $(".tablesorter").tablesorter(); 
     } 
    );
    $(document).ready(function() {

    //When page loads...
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function() {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });

});
    </script>
    <script type="text/javascript">
    $(function(){
        $('.column').equalHeight();
    });
</script>


</head>


<body>

    <header id="header">
        <hgroup>
            <h1 class="site_title"><a href="#">人力资源管理系统</a></h1>
            <h2 class="section_title"></h2><div class="btn_view_site"><a href="login.html">注销</a></div>
        </hgroup>
    </header> <!-- end of header bar -->
    
    <section id="secondary_bar">
        <div class="user">
            <p id="staff"></p>
            <!-- <a class="logout_user" href="#" title="Logout">Logout</a> -->
        </div>
        <div class="breadcrumbs_container">
            <article class="breadcrumbs"><a href="index.html">系统管理中心</a> <div class="breadcrumb_divider"></div> <a class="current">公告添加</a></article>
            <div class="current-time"></div>
        </div>
    </section><!-- end of secondary bar -->
    
    <aside id="sidebar" class="column">
    <h3>人员信息管理</h3>
    <ul class="toggle">
        <li class="icn_new_article"><a href="lecadd.html">人员信息录入</a></li>
        <li class="icn_see_onlineUser"><a href="leclist.html">人员信息查看</a></li>
        
    </ul>

        <h3>应聘信息管理</h3>
        <ul class="toggle">
            <li class="icn_new_article"><a href="hireinfo.html">应聘信息录入</a></li>
            <li class="icn_see_onlineUser"><a href="rencaiku.html">应聘信息查看</a></li>
            <li class="icn_categories"><a href="approval.html">应聘信息审核</a></li>
        </ul>
    
    <h3>公告管理</h3>
    <ul class="toggle">
        <li class="icn_new_article"><a href="notice_add.html">公告添加</a></li>

        <li class="icn_categories"><a href="notice_edit.html">公告编辑</a></li>

        <li class="icn_see_onlineUser"><a href="notice_check.html">公告查看</a></li>


        
    </ul>
    
    
    
    
    <footer>
        
    </footer>
</aside><!-- end of sidebar -->
    
    
    <section id="main" class="column">
       
            <article class="module width_full">
                <header><h3>公告添加</h3></header>
                    <div class="module_content" >
                            <fieldset>
                                <label>标题</label>
                                <input type="text" id="caption">
                            </fieldset>
                            <fieldset style="width:100%; float:left; margin-right:1%;">
                                <label>内容</label>
                                <textarea rows="12" id="content"></textarea>
                            </fieldset>
                            
                            <div class="clear"></div>            
                    </div>
                <footer>
                    <div class="submit_link">
                        <input type="hidden" name="id" value="{$data.id|default:''}">
                        <input type="submit" id="submit" value="发布" class="alt_btn">
                    </div>
                </footer>
            </article>
       
        <div class="spacer"></div>
    </section>


<script type="text/javascript">

    let notice_caption = document.getElementById("caption"),

        notice_content = document.getElementById("content"),

        submit = document.getElementById("submit");


    //检查公告的标题和内容是否为空

    function checkIsEmpty() {

        if(notice_caption.value == ""){


            alert("请输入公告的标题");

            return true;

        }else if(notice_content.value == ""){

            alert("请输入公告的内容");

            return true;

        }else {

            return false;
        }
    }

    //清空公告内容

    function notice_clear() {

        notice_caption.value = "";

        notice_content.value = "";
    }

    //发布公告
    submit.onclick = function () {

        if(checkIsEmpty())
        {
            return;
        }
        else{

            let data = {

                caption: notice_caption.value.trim(),

                content:notice_content.value.trim(),

                publisher:localStorage.getItem("username"),

                date:getCurrentTime()
            };

            boardApi.billboard.addBillboard(data, function(err, result) {
                if (err) {
                    alert(err);
                } else {
                    alert("公告发布成功");
                    notice_clear();
                    location.href = "notice_check.html"
                }
            });

        }
    }

    function getCurrentTime() {

        var date = new Date();

        var month = date.getMonth() + 1;

        var days = date.getDate();

        var year = date.getFullYear();

        var currentTime = year + "/" + month + "/" + days;

        return currentTime;
    }

</script>

    <script>

        let staff = document.getElementById("staff");

        $(staff).text(localStorage.getItem("username"));

    </script>


</body>

</html>